package com.xiaotao.user.domain.query;


import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.Min;


@Data
@Accessors(chain = true) //setter方法支持链式调用
public class PageQuery {
    public static final Integer DEFAULT_PAGE_SIZE = 20;
    public static final Integer DEFAULT_PAGE_NUM = 1;

    // 页码
    @Min(value = 1, message = "页码不能小于1")
    private Integer pageNo = DEFAULT_PAGE_NUM;

    // 每页大小
    @Min(value = 1, message = "每页查询数量不能小于1")
    private Integer pageSize = DEFAULT_PAGE_SIZE;

    // 是否升序
    private Boolean isAsc = true;

    //分类字段
    private String category;

    // 排序字段
    private String sortBy;

    public int from(){
        return (pageNo - 1) * pageSize;
    }

}
